<?php

function printProfiles($user_name, $user_surname, $user_email, $user_job, $profile, $id_user, $type_img) {
    switch ($type_img) {
        case 0 :
            $ext = 'png';
            break;
        case 1 :
            $ext = 'jpg';
            break;
        case 2 :
            $ext = 'jpeg';
            break;
        default :
            $ext = '';
            break;
    }
    echo '
            <div id="case3">
                <a href="' . URL_ROOT . 'profils/details-' . $profile . '">
                <img id="img_profile" src="' . URL_IMG . 'profiles/' . $id_user . '.' . $ext . '" alt="Voir le profil de ' . $user_surname . ' ' . $user_name . '" />
                </a>
            ';



    echo ' 
            
                <div id="profile">
                    <a href="' . URL_ROOT . 'profils/details-' . $profile . '">
                        <span id="profile_name">' ;
    if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) //pour détecter si le navigateur est IE
                  { 
                            echo' '.utf8_decode( $user_name) . ' ' .utf8_decode( $user_surname).'' ; 
                    }
                    else //les autres navigateurs 
                    {       
                        echo' '.$user_name. ' ' .$user_surname.' ';
                   }
                        echo'</span></br>
                        <span id="profile_description">';
                        if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) //pour détecter si le navigateur est IE
                  { 
                            echo' '.utf8_decode( $user_job) . '' ; 
                    }
                    else //les autres navigateurs 
                    {       
                        echo' '.$user_job.' ';
                   }
                            echo'</span></br>
                        <span id="profile_description">' . $user_email . ' </span></br>
                    </a>
                  <span id="profile_work"> <label id="attribut"> Oeuvres rep&eacute;r&eacute;es :</label>  
            
        
	';
}


function printOneProfile($user_description, $user_name, $user_surname, $user_email, $user_job, $id_user, $type_img) {

    switch ($type_img) {
        case 0 :
            $ext = 'png';
            break;
        case 1 :
            $ext = 'jpg';
            break;
        case 2 :
            $ext = 'jpeg';
            break;
        default :
            $ext = 'jpg';
            break;
    }
    echo '<span class="template_box"><img id="img_one_profile" src="' . URL_IMG . 'profiles/' . $id_user . '.'.$ext.' " />
                ';


    echo '
        <div id="profile">
           <span id="profile_name">' ;
    if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) //pour détecter si le navigateur est IE
                  { 
                            echo' '.utf8_decode( $user_name) . ' ' .utf8_decode( $user_surname).'' ; 
                    }
                    else //les autres navigateurs 
                    {       
                        echo' '.$user_name. ' ' .$user_surname.' ';
                   }
        echo'</span></br>
           <span id="profile_description">';
         if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) //pour détecter si le navigateur est IE
                  { 
                            echo' '.utf8_decode( $user_job) . '' ; 
                    }
                    else //les autres navigateurs 
                    {       
                        echo' '.$user_job.' ';
                   }
            echo'</span></br>
           <span id="profile_description">' . $user_email . ' </span>
           <span id="profile_description">' . $user_description . ' </span>
           <span id="profile_work"> <label id="attribut"> Oeuvres rep&eacute;r&eacute;es :</label>  
                  
	';
}

function printWork_OneProfile($work_name, $profile) {
    echo '
        
        
        <a id="profile_work_lien" href="' . URL_ROOT . 'oeuvres/details-' . $profile . '">';
            if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) //pour détecter si le navigateur est IE
                  { 
                            echo' '.utf8_decode( raccourcirOeuvres($work_name,20) ) . '   ' ; 
                           
                    }
                    else //les autres navigateurs 
                    {       
                        echo' '.raccourcirOeuvres($work_name,20) .'   ';
                       
                   }  
            echo'</a>  
            ';
            
              echo '   ';
}

function printspace() {
    echo'
        </span>
        </div>
        </div></span> ';
}

function raccourcirOeuvres($chaine, $tailleMax) {
    // Variable locale
    $positionDernierEspace = 0;
    if (strlen($chaine) >= $tailleMax) {
        $chaine = substr($chaine, 0, $tailleMax);
        $positionDernierEspace = strrpos($chaine, ' ');
        $chaine = substr($chaine, 0, $positionDernierEspace) . '...';
    }
    return $chaine;
}

?>
